<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <c:choose>
        <c:when test="${tenant.wechatName!=null && tenant.wechatName!=''}">
            <title>【${tenant.wechatName}】充电运营服务平台</title>
        </c:when>
        <c:otherwise>
            <title>【瑞晨云充充电】充电运营服务平台</title>
        </c:otherwise>
    </c:choose>
    <%@include file="/include/header.html" %>
    <link href="${ctx}/statics/css/login.css" rel="stylesheet">
    <link rel="stylesheet" href="${ctx}/statics/css/newEdition.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/bannerAlert/banneralert.css">
    <script src="${ctx}/libjs/plugins/jquery/jquery.min.js"></script>
    <script src="${ctx}/libjs/plugins/bannerAlert/banneralert.min.js"></script>
    <script src="${ctx}/libjs/plugins/flexible/flexible.js"></script>
    <script src="${ctx}/libjs/plugins/flexible/flexible_css.js"></script>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
</head>

<body class="newLoginBody" onKeyDown="submitForm()">
<div class="outsideLoginBox">
    <div class="loginLeft">
        <p class="p1">瑞晨云充充电运营管理平台</p>
        <p class="p2">瑞晨云充让充电运营更简单</p>
        <div class="bottomBg">
            <img src="${ctx}/statics/img/newEdition/loginCar.png" alt="">
        </div>
        <%--<c:choose>--%>
            <%--<c:when test="${tenant.tenantLogoImg!=null && tenant.tenantLogoImg!=''}">--%>
                <%--<img src="${tenant.tenantLogoImg}" class="enterpriseLogo" alt="">--%>
                <%--<p class="p1">${tenant.tenantName}，让充电运营更简单</p>--%>
                <%--<p class="p2">方便、快捷、高效的充电运营平台</p>--%>
            <%--</c:when>--%>
            <%--<c:otherwise>--%>
                <%--<img src="${ctx}/statics/img/newEdition/enterpriseLogo.png" class="enterpriseLogo" alt="">--%>
                <%--<p class="p1">瑞晨云，让充电运营更简单</p>--%>
                <%--<p class="p2">方便、快捷、高效的充电运营平台</p>--%>
                <%--<p class="editionParagraph">版权所有 ©2020 广东劲天科技有限公司</p>--%>
            <%--</c:otherwise>--%>
        <%--</c:choose>--%>
        <%--<div class="login_Yaxis"></div>--%>
    </div>
    <div class="loginRight">
        <%--<div class="titleTop">欢迎使用【瑞晨云】运营平台</div>--%>
        <form action="" id="signupForm">
            <div class="accountBox">
                <%--<p class="loginInfoTitle">账&nbsp;&nbsp;&nbsp;号</p>--%>
                    <img src="${ctx}/statics/img/newEdition/login_userIcon.png" class="inputIcon" alt="">
                <input type="text" name="username" class="form-control inputSize" placeholder="账号"
                       onkeyup="this.value=this.value.replace(/[, ]/g,'')">
            </div>
            <div class="pwdBox">
                <%--<p class="loginInfoTitle">密&nbsp;&nbsp;&nbsp;码</p>--%>
                    <img src="${ctx}/statics/img/newEdition/login_pwdIcon.png" class="inputIcon" alt="">
                <input type="password" name="password" class="form-control inputSize" placeholder="密码"
                       onkeyup="this.value=this.value.replace(/[, ]/g,'')">
            </div>
            <div class="login-error-msg pwdErrorMsg hide"><span class="login-error-icon"></span>账户或密码错误，请重新输入</div>
            <div class="yzmBox">
                <%--<p class="loginInfoTitle">验证码</p>--%>
                    <img src="${ctx}/statics/img/newEdition/login_codeIcon.png" class="inputIcon" alt="">
                <input type="text" name="verify" autocomplete="off" class="form-control inputSize" placeholder="验证码"
                       onkeyup="this.value=this.value.replace(/[, ]/g,'')">
            </div>
            <div class="login-error-msg codeErrorMsg hide"><span class="login-error-icon"></span>验证码错误，请重新输入</div>
            <div class="login-error-msg userErrorMsg hide"><span class="login-error-icon"></span>用户已冻结</div>
        </form>
        <div class="codeBox">
            <img class="code_image" src="${ctx}/captcha/genCaptcha" alt="验证码" title="点击换一张图片" style="cursor:pointer;"
                 onclick="this.src=this.src+'?'+Math.random(); ">
            <button type="button" class="updateCodeBtn" onclick="getCodeImg()"><span class="updateIcon"></span>刷新
            </button>
        </div>
        <div class="loginBtnBox">
            <button type="button" onclick="login()" class="loginBtn">登&nbsp;录</button>
        </div>
        <%--<div class="emptyBox"></div>--%>
        <%--<button type="button" style="top: 5rem" onclick="login()" class="loginBtn">登&nbsp;&nbsp;录</button>--%>
        <%--<button type="button" style="top: 5.5rem" onclick="login()" class="loginBtn">登&nbsp;&nbsp;录</button>--%>
    </div>
    <div class="blueLine"></div>
    <div class="blueTriangle"></div>
</div>
<%--<p class="bottom_tips">技术支持： 瑞晨云充信息技术有限公司</p>--%>
</body>

<script type="text/javascript">
    $(document).ready(function () {
        validateRule();
    });

    if (!!window.ActiveXObject || "ActiveXObject" in window) {
    } else {
        $(".shadeBox").css("width", "29%");
        $(".InputBox").css("width", "23%");
        $(".loginAll").css("top", '24.5%');
    }

    function login() {
        // document.getElementById('loginForm').submit();
        $.ajax({
            type: "POST",
            url: "${ctx}/goLoginning",
            data: $('#signupForm').serialize(),
            success: function (data) {
                console.log(data)
                if (data.status == "200") {
                    parent.location.href = '${ctx}/welcome';
                } else {
                    if (data.message == "用户名或密码不匹配") {
                        $(".pwdErrorMsg").removeClass("hide");
                        $(".codeErrorMsg").addClass("hide")
                    } else if (data.message == "验证码不匹配") {
                        $(".pwdErrorMsg").addClass("hide");
                        $(".codeErrorMsg").removeClass("hide")
                    } else {
                        $(".pwdErrorMsg").addClass("hide");
                        $(".codeErrorMsg").addClass("hide");
                        $(".userErrorMsg").removeClass("hide")
                    }
                }

            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: false
                },
                password: {
                    required: false
                },
                verify: {
                    required: false
                },

            },
            messages: {
                username: {
                    required: icon + "请输入帐号",
                },
                password: {
                    required: icon + "请输入密码",
                },
                verify: {
                    required: icon + "请输入验证码",
                }
            },
            submitHandler: function (form) {
                login();
            }
        })
    }

    function getCodeImg() {
        $.ajax({
            type: "GET",
            url: "${ctx}/captcha/genCaptcha",
            data: '',
            success: function (data) {
                $(".code_image").attr("src", "${ctx}/captcha/genCaptcha?" + Math.random())
            }
        });
    }

    setTimeout(function () {
        getCodeImg()
    }, 200)

    //回车提交表单
    function submitForm() {
        if (event.keyCode == 13) {
            login()
        }
    }

</script>

</html>
<script src="${ctx}/libjs/plugins/newEdition/newEdition.js"></script>